package com.example.cmtwo.controller;


import com.example.cmtwo.bean.Userinformation;
import com.example.cmtwo.service.AdminUserinformationservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


import java.util.*;


@Controller
public class AdminUserinformationController {
    @Autowired
    private AdminUserinformationservice adminUserinformationservice;
    private  Userinformation userinformation;



    @ResponseBody
    @RequestMapping(value = "/userinformation",method = RequestMethod.GET)
    public Map<Integer,Map> getuserinformation()
    {
        List<Userinformation> uif = new LinkedList<Userinformation>();
        Map<Integer,Map> list = new HashMap<Integer, Map>();
        uif = adminUserinformationservice.getUserinformationByall();
        Integer item=0;

        for (Iterator i =uif.iterator();i.hasNext();)
        {
            Map<String,String> map = new HashMap<String, String>();
            userinformation =(Userinformation) i.next();
            map.put("Uid",userinformation.getUid().toString());
            map.put("Name",userinformation.getName());
            map.put("Sno",userinformation.getSon());
            map.put("Idphoto",userinformation.getIdphoto());
            map.put("Head",userinformation.getHead());
            map.put("Sex",userinformation.getSex());
            map.put("QQ",userinformation.getQQ());
            map.put("Intro",userinformation.getIntro());
            list.put(item,map);
            item++;
        }

        return list;
    }
}
